package cn.tedu.uep.order.service.impl;

import cn.tedu.uep.order.pojo.entity.Order;
import cn.tedu.uep.order.pojo.vo.OrderVO;
import cn.tedu.uep.order.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Random;


@Slf4j
@Service
public class OrderServiceImpl implements OrderService {
    @Override
    public List<OrderVO> selectOrder(Long userId) {
        return null;
    }

    @Override
    public Order saveOrder() {
        log.debug("保存订单");
        Order order = new Order();
        order.setOrderId(getOrderNO());
        order.setStatus("0");
        order.setCreateTime(new Date());
        return order;
        //todo 申请单 调用此方法塞入 application_id \ user_id ——返回给我 我插入数据库
    }

    private String getOrderNO(){
        String start = "10000";
        Random random = new Random();
        int num = random.nextInt(10000);
        long now = System.currentTimeMillis();
        return start+"_"+now+"_"+num;
    }
}
